﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.Model;
using Register.DBUtility;
using System.Data;
using Register.IDAL;


/// <summary>
/// FileName: PayForRegistrantionviewDAL.cs
/// CLRVersion: 4.0.30319.1
/// Author: WBX
/// Corporation: 
/// Description: 
/// DateTime: 2012-7-9 11:51:21
/// </summary>

namespace Register.DAL
{
    class PayForRegistrantionviewDAL : IPayForRegistrantionviewDAL
    {

        private static string tableName = "PayForRegistrantion_view";
        public List<PayForRegistrantionview> GetList(string strWhere ,int pageIndex, int size)
        {
            DataSet set = DbHelperSQL.getPagedData("*", "PayForRegistrantion_AddTime", strWhere, "PayForRegistrantion_view", OrderBy.DESC, pageIndex, size);
            List<PayForRegistrantionview> list = DataSetToList(set);
            return list;
        }
        public int  GetListCount(string where)
        {
            int count = 0;
            StringBuilder str = new StringBuilder();
            str.Append(" select count(*) from ");
            str.Append(tableName);
            if (where != null)
            {
                str.Append(" where ");
                str.Append(where);
                count = (int)DbHelperSQL.GetSingle(str.ToString());
            }
            else
            {
                count = (int)DbHelperSQL.GetSingle(str.ToString());
            }
            return count;
         
        }
        private List<PayForRegistrantionview> DataSetToList(DataSet ds)
        {
            List<PayForRegistrantionview> list = new List<PayForRegistrantionview>();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                PayForRegistrantionview mi = new PayForRegistrantionview();
                mi.Appointment_ID = (String)row["Appointment_ID"];
                mi.Departments_ID = (String)row["Departments_ID"];
                mi.Departments_Name = (String)row["Departments_Name"];
                mi.Doctor_ID = (String)row["Doctor_ID"];
                mi.Hospital_ID = (String)row["Hospital_ID"];
                mi.Hospital_Name = (String)row["Hospital_Name"];
                mi.Outpatient_ID = (String)row["Outpatient_ID"];
                mi.Outpatient_OutpaitentType = (String)row["Outpatient_OutpaitentType"];
                mi.PayForRegistrantion_AddTime = (DateTime)row["PayForRegistrantion_AddTime"];
                mi.PayForRegistrantion_ID = (String)row["PayForRegistrantion_ID"];
                mi.PayForRegistrantion_Menory = (decimal)row["PayForRegistrantion_Menory"];
                mi.PayForRegistrantion_Recoder = (String)row["PayForRegistrantion_Recoder"];
                mi.PayForRegistrantion_Type = (String)row["PayForRegistrantion_Type"];
                mi.Register_ID = (String)row["Register_ID"];
                list.Add(mi);
            }
            return list;
        }
    }
}
